#include <stdio.h>

#define Nstu 30

struct student {
    int id, birthday;
    char name[32], major[32];
};

int main()
{
    int i, j, n, id;
    struct student stu[Nstu];
    for (i = 0; i < 30; i++) {
        scanf("%s%d%d%s", stu[i].name, &stu[i].birthday,
                &stu[i].id,  stu[i].major);
    }
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &id);
        for (j = 0; j < Nstu; j++)
            if (stu[j].id == id)
                break;
        if (j == Nstu)
            printf("Not found\n");
        else
            printf("%s %d %08d %s\n", stu[j].name, stu[j].birthday,
                    stu[j].id,  stu[j].major);
    }
    return 0;
}

